#include <iostream>
using namespace std;

int main() {
    int arrLen = 6;
    int list[arrLen][arrLen];
    for (int i = 1; i <= 5; i++) {
        for (int j = 1; j <= 5; j++)
        {
            cin >> list[i][j];
        }
    }
    int m,n;
    cin >> m >> n;    
    for (int j = 1; j <= 5; j++) {
        swap(list[m][j], list[n][j]);
    }

    for (int i = 1; i <= 5; i++) {
        for (int j = 1; j <= 5; j++) {
            cout << list[i][j] << " ";
        }
        cout << endl;
    }
    
    return 0;
}